varying vec3 lightDir,normal;
uniform sampler2D tex0, tex1;

void main()
{
	vec3 ct0,cf0, ct1, cf;
	vec4 texel0, texel1;
	float intensity,at0, at1,af;
	
	intensity = max(dot(lightDir,normalize(normal)),0.0);
	
	cf = intensity * (gl_FrontMaterial.diffuse).rgb + 
					  gl_FrontMaterial.ambient.rgb;
	af = gl_FrontMaterial.diffuse.a;
	
	texel0 = texture2D(tex0, gl_TexCoord[0].st);
	texel1 = texture2D(tex1, gl_TexCoord[0].st);
	ct0 = texel0.rgb;
	at0 = texel0.a;

	ct1 = texel1.rgb;
	at1 = texel1.a;
	
	gl_FragColor = vec4(ct1 * ct0 * cf, at1 * at0 * af);	
}